package com.pub.model;

import com.pub.util.MapUtil;
import com.pub.util.ResponseMessage;
import com.pub.util.ResponseStatus;

import java.util.HashMap;
import java.util.List;


public class ResponseModel {
    //消息
    private String message;
    //状态
    private int    status;
    //数据
    private Object data;
    public ResponseModel(){
        this.message = ResponseMessage.SUCESS;
        this.status  = ResponseStatus.SUCESS;
        this.data    = new HashMap<>();
    }
    //设置列表 total
    public void setError400(String message){
        this.status = 400;
        this.message = message;
    }
    //设置列表 model
    public void setListModel(List<Object> list,Object model){
        setListData(list, MapUtil.returnObjectEmptyValue(model));
    }
    //设置列表 total
    public void setListTotal(List<Object> list,int total){
        HashMap<String,Object> data = new HashMap<>();
        data.put("total",total);
        setListData(list,data);
    }
    //设置列表 HashMap
    public void setListData(List<Object> list,HashMap<String,Object> hashMap){
        HashMap<String,Object> data = new HashMap<>();
        data.put("list",list);
        data.putAll(hashMap);
        this.data = data;
    }
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
